package net.adetech.dcweb.core.utils.start;

import net.adetech.utils.UtilsCommon;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer;
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
 * Created by sunfeihu on 2017/4/12.
 */
@EnableTransactionManagement
@SpringBootApplication
@ComponentScan(basePackages = {"net.adetech.web.utils", "net.adetech.utils.spring", "net.adetech.dcweb.core.utils.**", "net.adetech.dcweb.core.**","net.adetech.**"})
public class Application implements EmbeddedServletContainerCustomizer {

    private static int port = 8080;

    public static void main(String[] args) {
        if (null != args && args.length > 0) {
            port = UtilsCommon.getInteger(args[0]);
        }
        SpringApplication.run(Application.class, args);
    }

    @Override
    public void customize(ConfigurableEmbeddedServletContainer configurableEmbeddedServletContainer) {
        configurableEmbeddedServletContainer.setPort(port);
    }

}